-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reduce file system corruption from standalone Lua scripts #5148
Conversation
@3djc should we add the check also when the buffer is not aligned on reads??? The code before the HAL change had the check on both. The write has it on both (aligned and not aligned buffers) Another difference with the "pre-hal" code is that that the disk status check (check the TRANSFER STATUS) is done if the read/write waiting for completion fails (currently we do only if succeeds).. the current code is short-cutting to "return" exit if the read/write waiting times out (failed). Other difference is the transfer status on the original code is in an infinite loop until succeed or fail the transfer (not time out), new code is with a timeout. should we use the version of the sdio_check_card.. without a timeout?? From the original HAL ticket: (also seems that all that code should be inside the read_dma/write_dma). Tried my proposed changes on my local branch and works, but did not solve the original problem with the LOGS corruption, but everything still works the same as before. |
On my local branch, i move the transfer check to inside the read_dma/write_dma:
|
Assuming that this PR "fixes" (actually, it masks it, but well) the original issue, I don't think adding all the clutter back is gonna help anyone here. |
@raphaelcoeffic agreed... this probably just make it harder to reproduce, but is not the fix to the root cause problem. |
Frankly, I'm still not convinced the SD block layer is at fault. Everything points at the way we use FatFs, and FatFs behaviour. |
You can do a quick test to lower the SDIO speed by changing a line, if it still fails, then it is not about DMA timing anyway. |
@richardclli I did lower the timing and still failed. I think probably put this to rest until we get others to report a similar problem. |
Standalone Lua such as the DSM Forward Programming tool do a lot of file system writing (logging) and appears to overrun some buffer in FafFs, writing file data right into the FAT, thus corrupting the file system. Using FF_FS_TINY=1 seems to mitigate this significantly, but does not appear to completely resolve this.
This possibly fixes LUA sd corruption. This PR is raised to allow easier testing
While at it, use more sdio_check_card_state_with_timeout();
Finding by @philmoz
This fixes #5077